import axios from "axios"

let instance = axios. create ({
     baseURL:'http://120.24.64.5:8088/mall-admin',
     timeout:5000
})

//请求拦截器
instance.interceptors.request.use((config)=>{
     //添加token
     let token = localStorage.getItem('token')
     if(token){
        config.headers && (config.headers['Authorization'] = token)
     }
     return config
},err=>Promise.reject(err)
)

//响应拦截器
instance.interceptors.response.use((res)=>{
    return res.data
    
},err=>Promise.reject(err)
)
export default instance